/* Copyright (c) 2025 Beijing Semidrive Technology Corporation
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/** ************************************************************************************************
 *  \file     Firewall_Ppc.h                                                                  *
 *  \brief    This file contains interface header for Semidrive Firewall PPC module.                    *
 *                                                                                                 *
 **************************************************************************************************/

#ifndef FIREWALL_PPC_H
#define FIREWALL_PPC_H

#ifdef __cplusplus
extern "C" {
#endif

/***************************************************************************************************
 *                                      Include header files                                       *
 **************************************************************************************************/
#include <Firewall.h>

/***************************************************************************************************
 *                                  Global Function Declarations                                   *
 **************************************************************************************************/
/**
 * \brief Configure the permission of peripherals in PPC module.
 *
 * This function configure the permission of peripherals in PPC module.
 * The permissions of peripherals in PPC module will be locked after configuring.
 * This function controls the features of interrupt and error response according
 * to the macro configuration.
 *
 * \param[in] base the address of the MAC module.
 * \param[in] ppc_cfg  The configuration of the apbmux IP permission.
 * \param[in] ip_num  The number of ip.
 *
 * \return The result of the PPC initialization function
 * \details - return FIREWALL_E_OK : Configurate PPC ip permission success.
 *          - return FIREWALL_E_NULL_POINTER : The pointer is a NULL_PTR.
 *          - return FIREWALL_E_PPC_IP_NUM : The number of peripherals is unvalid.
 */
lld_status_t Firewall_PpcIpConfigure(const Firewall_ControllerType *ctrl,
                const Firewall_PpcIpConfigType *ppc_cfg, uint16_t ip_num);

/**
 * \brief Configure the permission of peripherals' regions in PPC module.
 *
 * This function configure the permission of peripherals' regions in PPC module.
 * The permissions of regions will be locked after configuring.
 * This function controls the features of interrupt and error response according
 * to the macro configuration.
 *
 * \param[in] base the address of the MAC module.
 * \param[in] ppc_cfg  The configuration of the apbmux addr permission.
 * \param[in] region_num  The number of address region.
 *
 * \return The result of the PPC initialization function
 * \details - return FIREWALL_E_OK : Configurate PPC ip permission success.
 *          - return FIREWALL_E_NULL_POINTER : The pointer is a NULL_PTR.
 *          - return FIREWALL_E_PPC_REGION_NUM : The number of peripherals' regions is unvalid.
 */
lld_status_t Firewall_PpcAddrConfigure(const Firewall_ControllerType *ctrl,
                const Firewall_PpcAddrConfigType *ppc_cfg, uint16_t region_num);

/**
 * \brief Get the interrupt status of the PPC module.
 *
 * This function get the illegal access error information of the PPC module.
 * The function exits as soon as it gets an illegal access message.
 * This function should be called by the firewall interrupt handler
 * Firewall_IrqHandler().
 *
 * \param[in] base the address of the MAC module.
 *
 *  \return The illegal access error status of the PPC module.
 */
Firewall_PpcIrqStaType Firewall_PpcIrqHandler(uint32_t base);

/**
 * \brief Clear the interrupt status of the PPC module.
 *
 * This function clear the interrupt status of the PPC module.
 *
 * \param[in] base the base address of the MAC module.
 */
void Firewall_PpcClearInterrupt(uint32_t base);

/**
 * \brief Control the interrupt of illegal accessing for the PPC module.
 *
 * \param[in] base the address of the MAC module.
 * \param[in] enable Enable or disable the firewall interrupts
 */
void Firewall_PpcInterruptEnable(uint32_t base, bool enable);

/**
 * brief Enable Apb conguration compare feature in the PPC module.
 *
 * This function enable the Apb conguration compare in the PPC module.
 * This function should be called by Firewall_PpcAddrConfigure.
 *
 * param[in] base the address of the MAC module.
 */
void Firewall_PpcRegCompEnable(uint32_t base);

#ifdef __cplusplus
}
#endif

#endif /* FIREWALL_PPC_H */

/* End of file */
